home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8817 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  45 lines

  1. Newsgroups: comp.arch.arithmetic,comp.lang.c,comp.lang.c++
  2. Path: uu4news.netcom.com!zodiac!szh
  3. From: szh@zcon.com (Syed Zaeem Hosain)
  4. Subject: Re: Access carry flag from C
  5. Message-ID: <1996Feb26.175737.12702@zcon.com>
  6. Sender: szh@zcon.com (Syed Zaeem Hosain)
  7. Nntp-Posting-Host: zodiac
  8. Reply-To: szh@zcon.com
  9. Organization: Z Consulting Group
  10. References: <4gqj0d$d6p@airdmhor.gen.nz>
  11. Date: Mon, 26 Feb 1996 17:57:37 GMT
  12.  
  13. In article <4gqj0d$d6p@airdmhor.gen.nz>, gumboot@airdmhor.gen.nz (Simon Hosie) writes:
  14. >Lawrence Kirby:
  15. >> It certainly can be done portably although not with the efficiency that
  16. >> a platform-specific solution is likely to give you.
  17. >
  18. >>     int j, k;
  19. >
  20. >>     ...
  21. >
  22. >>     if ((j >= 0) ? (k > INT_MAX-j) : (k < INT_MIN-j))
  23. >                     ^^^^^^^^^^^^^^^   ^^^^^^^^^^^^^^^
  24. >  Won't they both be evaluated?
  25.  
  26. No. The conditional expression (j >= 0) determines which one of the
  27. other expressions is evaluated, and then this result is used for the
  28. "if" to be evaluated.
  29.  
  30. Think of it (inside the "if" of course) as:
  31.  
  32.     exp1 ? exp2 : exp3
  33.  
  34. and then it will be clearer.
  35.  
  36.  
  37.                             Z
  38.  
  39.  
  40. -- 
  41. -------------------------------------------------------------------------
  42. | Syed Zaeem Hosain          P. O. Box 610097            (408) 441-7021 |
  43. | Z Consulting Group        San Jose, CA 95161             szh@zcon.com |
  44. -------------------------------------------------------------------------
  45.